/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import beans.Name;
import service.UserService;

@Controller
public class UserController {
	
    @Autowired
    private UserService userService;
    
    @RequestMapping(value = "/user.html", method = RequestMethod.GET)
        public void simpleForm(Model model) {
        model.addAttribute(new Name());
    }
    
    @RequestMapping(value = "/user.html", method = RequestMethod.POST)
    public void simple(@ModelAttribute Name name, Model model) {
        model.addAttribute("name", name.getFirstName());
    }

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public UserService getUserService() {
		return userService;
	}
    
//    @RequestMapping(value = "user/{userName}", method = RequestMethod.POST)
//    public String show(@PathVariable("userName") String userName, Model model) {
////        Assert.notNull(userName, "username must be provided.");
//        model.addAttribute(userService.findUser(userName));
//        
//        return "user/show";
//    }
}
